package com.bwie.bwedu.fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.bwie.bwedu.R;
import com.bwie.bwedu.presenter.impl.PasswordUpdPresenterImpl;
import com.bwie.bwedu.ui.ClearEditText;
import com.bwie.bwedu.view.BaseView;

/**
 * Created by Administrator on 2016/7/21.
 *
 */
public class PasswordUpdFragment extends BaseFragment implements BaseView {

    private View view;
    private ClearEditText oldPwd;
    private ClearEditText newPwd;
    private ClearEditText newPwdAgain;
    private Button commit;
    private PasswordUpdPresenterImpl presenter;

    @Override
    public View getView(LayoutInflater inflater) {
        view = inflater.inflate(R.layout.fragment_pwd_upd,null);
        return view;
    }

    @Override
    public void findView() {
        oldPwd = (ClearEditText) view.findViewById(R.id.pwd_upd_old);
        newPwd = (ClearEditText) view.findViewById(R.id.pwd_upd_new);
        newPwdAgain = (ClearEditText) view.findViewById(R.id.pwd_upd_new_again);
        commit = (Button) view.findViewById(R.id.pwd_upd_commit);
    }

    @Override
    public void setData() {

        presenter = new PasswordUpdPresenterImpl(this);
    }

    @Override
    public void setListener() {
        commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.pwdUpd(oldPwd.getText().toString(),newPwd.getText().toString(),newPwdAgain.getText().toString());
            }
        });
    }

    @Override
    public void onSuccess() {
        getActivity().finish();
    }

    @Override
    public void onFail(String info) {
        showToast(info+"");
    }
}
